
include('shared.lua')


/*---------------------------------------------------------
   Name: Initialize
---------------------------------------------------------*/
function ENT:Initialize()
	
	self.Color = Color( 255, 225, 255, 255 )
	ownindex = tostring(self.Entity:EntIndex())
	
end

/*---------------------------------------------------------
   Name: DrawPre
---------------------------------------------------------*/



function ENT:Draw()	

	self:DrawEntityOutline( 0 )
	self.Entity:DrawModel()
	
		local codestring1 = self.Entity:GetNetworkedInt("pos1")
		local codestring2 = self.Entity:GetNetworkedInt("pos2")
		local codestring3 = self.Entity:GetNetworkedInt("pos3")
		local codestring4 = self.Entity:GetNetworkedInt("pos4")
		local codestring5 = self.Entity:GetNetworkedInt("meshheight")
		local codestring6 = self.Entity:GetNetworkedInt("showmesh")
		local codestring7 = self.Entity:GetNetworkedString("meshmat")
 
	if codestring1 ~= nil and codestring2 ~= nil and codestring3 ~= nil and codestring4 ~= nil and codestring5 ~= nil and codestring6 == 1 and codestring7 ~= nil then  
	
	local rpos1 = tonumber(codestring1)
	local rpos2 = tonumber(codestring2)
	local rpos3 = tonumber(codestring3)
	local rpos4 = tonumber(codestring4)
	local clothheight = tonumber(codestring5)
	local ourmeshmat = Material(codestring7)
	
	local fpos1 = ents.GetByIndex(rpos1)
	local fpos2 = ents.GetByIndex(rpos2)
	local fpos3 = ents.GetByIndex(rpos3)
	local fpos4 = ents.GetByIndex(rpos4)

	local pos1 = fpos1:GetPos() + Vector(0,0,clothheight)
	local pos2 = fpos2:GetPos()	+ Vector(0,0,clothheight)
	local pos3 = fpos3:GetPos()	+ Vector(0,0,clothheight)
	local pos4 = fpos4:GetPos()	+ Vector(0,0,clothheight)
	
	local pos5 = fpos1:GetPos()	- Vector(0,0,clothheight)
	local pos6 = fpos2:GetPos()	- Vector(0,0,clothheight)
	local pos7 = fpos3:GetPos()	- Vector(0,0,clothheight)
	local pos8 = fpos4:GetPos()	- Vector(0,0,clothheight)

	render.SetMaterial( ourmeshmat )
	surface.SetDrawColor(255, 255, 255, 255)
	render.DrawQuad(pos1, pos2, pos3, pos4)

end

end

